package authz

import (
	"github.com/casbin/casbin"
	"dhfshop/utils/helper"
	"errors"
)

var (
	EnforcerIn    *casbin.Enforcer
)

func StartAuthz(modelcfg, policycfg string) error {
	exist, _:= helper.PathExists(modelcfg)
	if !exist {
	    return errors.New("model file is not exist")
	}
	exist, _= helper.PathExists(policycfg)
	if !exist {
	    return errors.New("policy file is not exist")
	}
	EnforcerIn = casbin.NewEnforcer(modelcfg, policycfg)
	//EnforcerIn.AddRoleForUser("alice", "admin")
	//EnforcerIn.AddPolicy(...)
	return nil
}
